(function() {
  var scaleW = window.innerWidth / 375;
  var scaleH = window.innerHeight / 602;
  var resizes = document.querySelectorAll('.resize');

  var $swiperContainer = $('.swiper-container');

  setInterval(getData,"2000");

  function getData() {
    // http://121.40.135.115:8180/fotile-api-0.0.2/map/save.json
    //http://121.40.135.115:8180/fotile-api-0.0.2/map/get.json
    var url = 'http://121.40.135.115:8180/fotile-api-0.0.2/map/get.json';
    var parameter = {property : 'key', value: ''}
    // $.post(url, pra, function(data) {
    //   console.log(data);
    //   console.log('2s-load');
    //   $('.text-02').text('小于'+data.data.time+'分钟');
    //   $('.text-03').text('当前排队人数:'+data.data.people+'人');
    //   // lalert('submit success!');
    // },"json");
    $.ajax({

      url: url,

      data: parameter,

      type: "POST",

      contentType: "application/json; charset=utf-8",

      dataType:'json',

      success:function(res){
        console.log(res);
        $('.text-02').text('小于'+data.data.time+'分钟');
        $('.text-03').text('当前排队人数:'+data.data.people+'人');
      },

      error:function(er){
        console.log('请求错误');
      },
      headers: {
            "Access-Control-Allow-Origin":"*",
            "Access-Control-Allow-Methods":"POST",
            "Access-Control-Allow-Headers":"x-requested-with,content-type"
      }

    });
  }

  function lalert(msg) {
    layer.open({
      content: msg,
      skin: 'msg',
      time: 2
    });
  }

  for (var j = 0; j < resizes.length; j++) {
    if (resizes[j].getAttribute('data-resize-only') === 'top') {
      resizes[j].style.top = parseInt(resizes[j].style.top, 10) *
        scaleH +
        'px';
    } else {
      resizes[j].style.width = parseInt(resizes[j].style.width,
          10) *
        scaleW +
        'px';
      resizes[j].style.height = parseInt(resizes[j].style.height,
          10) *
        scaleH + 'px';
      if (resizes[j].getAttribute('data-resize-h') === 'right') {
        resizes[j].style.right = parseInt(resizes[j].style.right,
            10) *
          scaleW +
          'px';
      } else {
        resizes[j].style.left = parseInt(resizes[j].style.left,
            10) *
          scaleW +
          'px';
      }

      if (resizes[j].getAttribute('data-resize-v') === 'bottom') {
        resizes[j].style.bottom = parseInt(resizes[j].style.bottom,
            10) *
          scaleH +
          'px';
      } else {
        resizes[j].style.top = parseInt(resizes[j].style.top,
            10) *
          scaleH +
          'px';
      }
    }
  }

  // $('.form-btn').on('click', function() {
  //   var for_form = $(this).data('for-form');
  //   var $form = $('#' + for_form);
  //   var url = 'http://121.40.135.115:8180/fotile-api-0.0.2/map/save';
  //
  //   var count = $form.find('input[name=input-count]').val();
  //   if (count) {
  //     url += "property[人数]=" + count;
  //   } else {
  //     lalert('please input count');
  //     return;
  //   }
  //
  //   var time = $form.find('input[name=input-time]').val();
  //   if (time) {
  //     url += "&value[姓名]=" + time;
  //   } else {
  //     lalert('please input time');
  //     return;
  //   }
  //
  //   console.log(url);
  //   layer.open({
  //     type: 2
  //   });
  //   $.post(url, function(data) {
  //     console.log(data);
  //     layer.closeAll();
  //     lalert('submit success!');
  //     if (for_form === 'modal') {
  //       $('.form-wrapper').removeClass('show').addClass('hide');
  //     }
  //     // clearForm($form);
  //   });
  // });
  //
  // function clearForm($form) {
  //   var names = ['city', 'name', 'phone', 'job', 'ideal', 'check-in-1', 'location', 'check-in-2', 'rent'];
  //   for (var i = 0; i < names.length; i++) {
  //     $form.find('input[name=input-' + names[i] + ']').val('');
  //   }
  //   $form.find('.pic').each(function(i) {
  //     $(this).remove();
  //   });
  // }





  // var mySwiper = new Swiper('.swiper-container', {
  //   direction: 'vertical',
  //   pagination: '.swiper-pagination',
  //   //virtualTranslate : true,
  //   mousewheelControl: true,
  //   onInit: function(swiper) {
  //     swiperAnimateCache(swiper);
  //     swiperAnimate(swiper);
  //   },
  //   onSlideChangeEnd: function(swiper) {
  //     swiperAnimate(swiper);
  //   },
  //   onTransitionEnd: function(swiper) {
  //     swiperAnimate(swiper);
  //     if (swiper.activeIndex === 0) {
  //       $topBar.removeClass('show');
  //     } else {
  //       $topBar.addClass('show');
  //     }
  //   },
  //   watchSlidesProgress: true,
  //   onProgress: function(swiper) {
  //     for (var i = 0; i < swiper.slides.length; i++) {
  //       var slide = swiper.slides[i];
  //       var progress = slide.progress;
  //       var translate = progress * swiper.height / 4;
  //       scale = 1 - Math.min(Math.abs(progress * 0.5),
  //         1);
  //       var opacity = 1 - Math.min(Math.abs(progress /
  //         2), 0.5);
  //       slide.style.opacity = opacity;
  //       es = slide.style;
  //       es.webkitTransform = es.MsTransform = es.msTransform =
  //         es.MozTransform = es.OTransform = es.transform =
  //         'translate3d(0,' + translate + 'px,-' +
  //         translate + 'px) scaleY(' + scale + ')';
  //     }
  //   },
  //   onSetTransition: function(swiper, speed) {
  //     for (var i = 0; i < swiper.slides.length; i++) {
  //       es = swiper.slides[i].style;
  //       es.webkitTransitionDuration = es.MsTransitionDuration =
  //         es.msTransitionDuration = es.MozTransitionDuration =
  //         es.OTransitionDuration = es.transitionDuration =
  //         speed + 'ms';
  //     }
  //   },
  // });


  // $.getJSON('http://job-in.cc/api/tool.accesslog/jsonp?_callback=?&url=' + encodeURIComponent(window.location.href), function(data) {
  //   console.log(data);
  // });
})();

// (function() {
//   $.getJSON('http://job-in.cc/api/tool.wxconfig/jsonp?_callback=?&url=' + encodeURIComponent(window.location.href), function(data) {
//     console.log(data);
//     if (data.code === 0) {
//       wx.config(data.value);
//     }
//   });
//
//   wx.ready(function() {
//     //$player.play();
//     console.log('ready');
//     wx.onMenuShareAppMessage({
//       title: 'Job-IN First Roommate Invitation',
//       desc: 'One solution to solve all your rental problems',
//       link: window.location.origin + window.location.pathname,
//       imgUrl: window.location.origin + window.location.pathname + 'image/p0-logo.png',
//       success: function() {}
//     });
//     wx.onMenuShareTimeline({
//       title: 'Job-IN First Roommate Invitation',
//       link: window.location.origin + window.location.pathname,
//       imgUrl: window.location.origin + window.location.pathname + 'image/p0-logo.png',
//       success: function() {}
//     });
//   });
//
// })();
